package edu.lambdateacher.parser;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import edu.lambdateacher.PropertiesManager;

/*
LambdaTeacher
Copyright (C) 2000  Kim Mason
Copyright (C) 2014  Vitalij Zadneprovskij

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/**
 * for different types of token
 *
 */
public enum LambdaTokenType {
	
	LAMBDA('\\',PropertiesManager.LAMBDA_CHAR),
	PERIOD('.'),
	LPAREN('('),
	RPAREN(')'),
	IDENT(),
	LET,
	EQUALS('='),
	PLUS('+'),
	MINUS('-'),
	STAR('*'),
	SLASH('/'),
	NUMBER,
	EOF,
	UNKNOWN;
	
	private final static Logger LOG = Logger.getLogger(LambdaTokenType.class);
	
	private static Map<Character,LambdaTokenType> charMap = new HashMap<Character,LambdaTokenType>();
	private List<Character> values = new ArrayList<Character>();
	
	static{
		for(LambdaTokenType type: LambdaTokenType.values()){
			//log.debug(type.values);
			for(Character c: type.values){
				charMap.put(c, type);
			}
		}
		LOG.debug(charMap);
	}
	
	LambdaTokenType(char... charList){
		for(char c:charList){
			this.values.add(c);
		}
	}

	public static Map<Character, LambdaTokenType> getCharMap() {
		if(charMap==null){
			charMap = new HashMap<Character,LambdaTokenType>();
		}
		return charMap;
	}

	private void setCharMap(Map<Character, LambdaTokenType> charMap) {
		LambdaTokenType.charMap = charMap;
	}
	
}
